<?php
/**
 * Created by PhpStorm.
 * User: mrlifang
 * Date: 17/5/7
 * Time: 下午4:24
 */

namespace Admin\Model;


use Frame\Libs\BaseModel;

class ArticleModel extends BaseModel
{
    protected $table = "article";

    /*
     * 获取链表查询的文章数据
     */
    public function fetchAllWithJoin($where="2>1",$orderby = 'id desc' ,$startrow=0,$pagesize = 10){
        //构建链表查询的SQL语句
        $sql = "SELECT article.*,category2.classname,user.username FROM article
                LEFT JOIN category2 ON article.category_id=category2.id
                LEFT JOIN user on article.user_id=user.id";
//        $sql .= "WHERE {$where}";
//        $sql .= "ORDER BY {$orderby}";
//        $sql .= "WHERE {$where}";
//        $sql .= "LIMIT {$startrow},{$pagesize}";

        $sql .= " WHERE {$where} ORDER BY {$orderby} LIMIT {$startrow},{$pagesize}";
        //echo $sql; exit();
        //执行SQL语句并返回二维数组
        return $this->pdo->fetchAll($sql);
    }

}